<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../js/vue.js"></script>
</head>
<style>
    .menu {
        position: fixed;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 40px;
        line-height: 40px;
        display: flex;
        align-items: center;
    }

    .menu .item {
        text-align: center;
        flex: 1;
        background-color: #000;
        color: tomato;
        border-right: 1px solid #fff;
    }

    .menu .active {
        background-color: #6ff;
    }
</style>

<body>
    <div id="app">
        <components :is="com"></components>
        <div class="menu">
            <div class="item" v-for="item in list" @click="changeIndex(item)" :class="{active:activeIndex==item.id}">
                {{item.msg}}</div>
        </div>

    </div>
</body>
<template id="mine">
    <div>
        个人
    </div>
</template>
<template id="list">
    <div>
        列表
    </div>
</template>
<template id="props">
    <div>
        父传子
        <child></child>
        <child num="999"></child>
        <child :num="n"></child>
    </div>
</template>
<template id="child">
    <div>
        子元素 来自父元素传的数据{{num}}
    </div>
</template>

<script>
    let child = {
        template: "#child",
        props: ["num"]
    }
    let mine = {
        template: "#mine",
    };
    let list = {
        template: "#list"
    };
    let about = {
        template: `<div>关于</div>`
    };
    let props = {
        template: "#props",
        data() {
            return {
                n: 888
            }
        },
        components: {
            child
        }
    }

    new Vue({
        el: "#app",
        data: {
            activeIndex: 1,
            com: "list",
            list: [
                {id: 1, msg: "个人", com: "mine"},
                {id: 2, msg: "列表", com: "list"},
                {id: 3, msg: "关于", com: "about"},
                {id: 4, msg: "父传子", com: "props"},
            ]
        },
        methods: {
            changeIndex(item) {
                this.com = item.com;
                this.activeIndex = item.id;
            }
        },
        components: {
            mine,
            list,
            about,
            props,
        }
    })
</script>

</html>